<div class="pagenav">
	<a>演示</a> 
	<span class="pagenav-separator">/</span> 
	<a>表格</a>
</div>
<div class="layui-card">
	<div class="pagetools layui-clear">
		<div class="search">
			<form class="layui-form" >
				<div class="layui-inline">
					<label>关键字：</label>
				    <div class="layui-input-inline">
				        <input  placeholder="请输入关键字" autocomplete="off" class="layui-input">
				    </div>
			    </div>
			    <div class="layui-inline">
		    		<button lay-submit lay-filter="searchForm" class="layui-btn"><i class="iconfont icon-search"></i> 查询</button>
		    	</div>
			</form>
		</div>
		<div class="right-btns">
			<button class="layui-btn bg-forgive"  data-render="/demo/table/_form" data-target="dialog"  data-pageid=testEdit  data-option='{title:"添加"}'><i class="iconfont icon-add"></i> 添加</button>
		</div>
	</div>
		
	<div class="layui-card-body">
		<table   id="table1" lay-filter="tableFilter"></table>
	</div>
</div>
<!-- <a class="layui-btn layui-btn-xs" lay-event="detail" data-render="_form" data-option='{title:"编辑"}' data-pageid="testEdit" data-target="dialog" data-data="{editId : {{ d.id }} }">查看</a> -->
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script type="text/javascript">
layui.use(["tablePage", "table", "admin"], function(){
	var admin = layui.admin;
	var table = layui.table;
	var TPage = layui.tablePage;
	var tpage = TPage.create("#table1", "/data/table1", {
		cols:[[
			{field:'name',title:"人物"},
			{field:'nation',title:"民族"},
			{field:'outTime',title:"出场时间"},
			{field:'motto',title:"格言"},
			{width:180, align:'center', toolbar: '#barDemo'}
		]],
		searchFilter : 'searchForm'
	});
	tpage.load();
	
	table.on('tool(tableFilter)',function(obj){
		var data = obj.data; 
		var layEvent = obj.event; 
		 if(layEvent === 'edit'){ //查看
			 admin.render("_form", "dialog", {
				 title:"修改",
				 p : {data},
				 pageId: "testEdit",
				 end : function(isOk){
					 isOk && tpage.load();
				 }
			 });
		 }
	});
	
	window.onRefresh = function(){
		tpage.load();
	}
	

	
})


</script>